package com.ctbri.gui;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;

import com.ctbri.util.SwingConsole;

public class Ex5 extends JFrame {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private JTextField textField;
	private JButton button1, button2, button3;
	private ActionListener al = new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			String text = ((JButton)e.getSource()).getText();
			textField.setText(text);
		}
	};
	public Ex5() {
		textField = new JTextField(10);
		button1 = new JButton("Button 1");
		button2 = new JButton("Button 2");
		button3 = new JButton("Button 3");
		button1.addActionListener(al);
		button2.addActionListener(al);
		button3.addActionListener(al);
		setLayout(new FlowLayout());
		add(button1);
		add(button2);
		add(button3);
		add(textField);
	}
	
	public static void main(String[] args) {
		SwingConsole.run(new Ex5(), 500, 150);
	}
}
